package com.atguigu.gmall.web.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;

/**
 * 登录页
 */
@Controller
public class LoginController {

    //login.html
    @GetMapping("/login.html")
    public String loginPage(@RequestParam("originUrl") String originUrl,
                            Model model, HttpServletResponse response) {

//        Cookie cookie = new Cookie("haha", "hehe");
//        cookie.setDomain(".gmall.com"); //只要是访问gmall.com的任何域名都携带
//        // > 0 的数字，秒为单位
//        //正数： 多久后过期
//        //   0: cookie 立即删除
//        //默认：会话期有效；
////        cookie.setMaxAge(60*60);
//        response.addCookie(cookie);


        model.addAttribute("originUrl", originUrl);
        return "login";//登录页  classpath:/templates/login.html
    }

    @GetMapping("/login")
    public String login() {

        return "login";
    }
}
